package com.sec.etech.form.cust.executor.parseval;

import org.openbpm.bus.executor.parseval.ParseValExecuteChain;
import org.openbpm.bus.executor.parseval.ParseValParam;
import org.openbpm.bus.model.BusinessColumn;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

@Primary
@Service
public class CustParseValTypeExecutor
        extends ParseValExecuteChain {
    public int getSn() {
        return 0;
    }


    protected void run(ParseValParam param) {
        String key = param.getKey();
        Object value = param.getValue();

        if (value == null
            //       || StringUtil.isEmpty(value.toString())
        ) {
            return;
        }

        BusinessColumn column = param.getBusTableRel().getTable().getColumnByKey(key);
        if (column == null) {
            param.getData().put(key, value);

            return;
        }
        // fix bug 仅对字符串有效
        if("".equals(value) && "varchar".equals(column.getType())){
            param.getData().put(column.getKey(), value);
        }else{
            param.getData().put(column.getKey(), column.value(value.toString()));
        }

    }
}
